﻿using System.Windows.Forms;

namespace CC.Yacht.Windows.Forms
{
    public static class ControlExtensions
    {
        public static void AppendTextEx(this Control control, string text)
        {
            if (control.InvokeRequired)
            {
                control.BeginInvoke(new MethodInvoker(() => control.SetText(text)));
            }
            else
            {
                control.Text += text + "\r\n";
            }
        }

        public static void SetText(this Control control, string text)
        {
            if (control.InvokeRequired)
            {
                control.BeginInvoke(new MethodInvoker(() => control.SetText(text)));
            }
            else
            {
                control.Text = text;
            }
        }
    }
}
